<extend name="Public:baseAjax" />
<block name="content">
<Widget:show bdcls="no-padding" title="模型设计" col="12">
    <div class="table-responsive">
        <table class="table table-bordered">
            <thead>
                <th>字段名称</th>
                <th>标题</th>
                <th>表单类型</th>
                <th>字段类型</th>
                <th>col长度</th>
                <th>列表</th>
                <th>新增</th>
                <th>编辑</th>
            </thead>
            <tbody>
            <volist name="vo[fields]" id="v">
            <tr>
                <td>{$v.name}</td>
                <td><a data-editable data-name="label" data-value="{$v.label}" data-pk="{$v.name}" href="#">{$v.label}</a></td>
                <td><a data-type="select" data-editable-ipttype data-name="type" data-value="{$v.type}" data-pk="{$v.name}" href="#"></a> </td>
                <td><a data-type="select" data-editable-ipttype data-name="type" data-value="{$v.type}" data-pk="{$v.name}" href="#"></a> </td>
                <td><a data-editable data-name="col" data-value="{$v.col}" data-pk="{$v.name}" href="#">{$v.col}</a></td>
                <td><a data-type="select" data-editable-isshow data-name="showList" data-value="{$v.showList}" data-pk="{$v.name}" href="#"></a></td>
                <td><a data-type="select" data-editable-isshow data-name="showAdd" data-value="{$v.showAdd}" data-pk="{$v.name}" href="#"></a></td>
                <td><a data-type="select" data-editable-isshow data-name="showEdit" data-value="{$v.showEdit}" data-pk="{$v.name}" href="#"></a></td>
            </tr>    
            </volist>
            </tbody>
        </table>
    </div>
</Widget:show>
<script type="text/javascript">
pageSetUp();
var pagefunction = function() {

    $("select[name=model]").on('change',function(){
        var hash  = window.location.hash;
        var name = $(this).val();
        hash = U('name',name,hash);
        window.location.hash = hash;
        console.log(hash);
    })


    loadScript("assets/js/plugin/x-editable/moment.min.js", loadMockJax);
    
    function loadMockJax() {
        loadScript("assets/js/plugin/x-editable/jquery.mockjax.min.js", loadXeditable);
    }

    function loadXeditable() {
        loadScript("assets/js/plugin/x-editable/x-editable.min.js", loadTypeHead);
    }

    function loadTypeHead() {
        loadScript("assets/js/plugin/typeahead/typeahead.min.js", loadTypeaheadjs);
    }

    function loadTypeaheadjs() {
        loadScript("assets/js/plugin/typeahead/typeaheadjs.min.js", runXEditDemo);
    }

    function runXEditDemo() {
        $.fn.editable.defaults.url = "{:U('Admin/updateField')}&mName={$Think.get.name}";
        $('[data-editable]').editable();

        $('[data-editable-isshow]').editable({
            prepend: "隐藏",
            source: [
                {value: '1', text: '显示'},
                {value: '0', text: '隐藏'},
            ]
        });


        $('[data-editable-ipttype]').editable({
            prepend: "请选择",
            source: [
                {value: 'input', text: 'input'},
                {value: 'text', text: 'text'},
                {value: 'password', text: 'password'},
                {value: 'select', text: 'select'},
                {value: 'number', text: 'number'},
                {value: 'date', text: 'date'},
                {value: 'time', text: 'time'},
                {value: 'datetime', text: 'datetime'},
                {value: 'hidden', text: 'hidden'},
                {value: 'checkbox', text: 'checkbox'},
                {value: 'textarea', text: 'textarea'},
                {value: 'editor', text: 'editor'},
                {value: 'file', text: 'file'},
                {value: 'fileinput', text: 'fileinput'},
            ]
        });
    }



}
pagefunction();
</script>

</block>
